#include "BubbleSort.h"
void BubbleSort(std::vector<TYPE> &nums,bool miniToMax)
{
    bool BubbleFlage = true;
    while (BubbleFlage){
        BubbleFlage = false;
        for (int i = 1; i < nums.size(); ++i) {
            if(miniToMax){
                if(nums[i] < nums[i-1]){
                    std::swap(nums[i], nums[i-1]);
                    BubbleFlage = true;
                }
            }else {
                if(nums[i] > nums[i-1]){
                    std::swap(nums[i], nums[i-1]);
                    BubbleFlage = true;
                }
            }
        }
    }
}
void show(std::vector<TYPE> &nums){
    std::cout<<"nums:";
    for (int i = 0; i < nums.size(); ++i) {
        std::cout<<nums[i]<<",";
    }std::cout<<std::endl;
}

int main(){
    std::vector<int> nums = {1,3,5,7,2,6,4,8,9,2,8,7,6,0,3,5,9,4,1,0};
    show(nums);
    BubbleSort(nums,true);
    show(nums);
    std::vector<int> nums1 = {1,3,5,7,2,6,4,8,9,2,8,7,6,0,3,5,9,4,1,0};
    show(nums1);
    BubbleSort(nums1, false);
    show(nums1);
    return 0;
}